import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smt/table/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 详情-基础信息
export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/smt/table/detail',
    method: 'get',
    params: {
      id
    }
  });
};

// 详情-站位表分页
export const getTrackList = (current, size, tableId) => {
  return request({
    url: '/api/mes-product/smttable/track/page',
    method: 'get',
    params: {
      tableId,
      current,
      size
    }
  });
};

// 详情-修改日志
export const getLogDetail = (name) => {
  return request({
    url: '/api/mes-product/smt/table/history',
    method: 'get',
    params: {
      name
    }
  });
};

export const getTrackSheetList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smttable/feeding-track-sheet-page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getTrackDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/track/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/smt/table/remove',
    method: 'get',
    params: {
      ids
    }
  });
};
// 启用
export const enable = (ids) => {
  return request({
    url: '/api/mes-product/smt/table/able',
    method: 'get',
    params: {
      ids,
      status: 1
    }
  });
};

// 禁用
export const disable = (ids) => {
  return request({
    url: '/api/mes-product/smt/table/able',
    method: 'get',
    params: {
      ids,
      status: 0
    }
  });
};

export const removeTrack = (ids) => {
  return request({
    url: '/api/mes-product/smttable/track/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const addTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const updateTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

// 替代料详情
export const getTrackReplaceDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/track/replace/detail',
    method: 'get',
    params: { id }
  });
};

/**
 * 验证机台编码、产品编码
 */
export const verifyMachineCodeOrPartNo = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/check-table-machine-code-part-no',
    method: 'post',
    data: row
  });
};

/**
 * 获取已选中的产品数据
 */
export const getSelectedProduct = (array) => {
  return request({
    url: '/api/mes-admin/partmaster/list-part-master',
    method: 'post',
    data: array
  });
};

export const importData = (formData, url) => {
  return request({
    url: '/api/mes-product' + url,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
//慧眼导入
export const importDataByHY = (formData) => {
  return request({
    url: '/api/mes-product/smttable/stationHYImport/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// 机型导入
export const importMechineData = (formData) => {
  return request({
    url: '/api/mes-product/smttable/mechineModel/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// 设备型号导入
export const importMechineModelData = (formData) => {
  return request({
    url: '/api/mes-product/smttable/mechineModelLlz/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
// 机型检验
export const checkMechineImportData = (formData) => {
  return request({
    url: '/api/mes-product/smttable/mechineModel/check',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
// 设备型号检验
export const checkMechineModelImportData = (formData) => {
  return request({
    url: '/api/mes-product/smttable/mechineModelLlz/check',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
// 慧眼检查
export const checkMechineImportDataByHY = (formData) => {
  return request({
    url: '/api/mes-product/smttable/stationHYImport/check',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

export const checkImportData = (formData, url) => {
  return request({
    url: '/api/mes-product' + url,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

export const updateTable = (data) => {
  return request({
    url: '/api/mes-product/smttable/tableAndTrack/submit',
    method: 'post',
    data: data
  });
};

export const getSmtType = (params) => {
  return request({
    url: '/api/blade-system/param/list?paramKey=smt_import_type&current=1&size=1',
    method: 'get',
    params: params
  });
};

export const getSmtCheckType = (params) => {
  return request({
    url: '/api/blade-system/param/list?paramKey=smt_import_check&current=1&size=1',
    method: 'get',
    params: params
  });
};

export const getSmtImportType = (params) => {
  return request({
    url: '/api/blade-system/param/list?paramKey=smt_import_interface&current=1&size=1',
    method: 'get',
    params: params
  });
};
